﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Drawing2D;
using System.Drawing;

namespace Backend
{
    public enum ThumbnailFixedType
    {
        WIDTH_FIX,
        HEIGHT_FIX
    }
    public class ThumbnailInfos<T>
    {
        private T item_ {get;set;}
        private ThumbnailFixedType fixType_ { get; set; }
        private float fixLength_ { get; set; }
        private SizeF ori_size_ { get; set; }
        public ThumbnailInfos(T item, ThumbnailFixedType type, float fixlength, SizeF originalSize)
        {
            item_ = item;
            fixType_ = type;
            fixLength_ = fixlength;
            ori_size_ = originalSize;
        }

        public T Item
        {
            get
            {
                return item_;
            }
        }

        public SizeF ThumbSize
        {
            get
            {
                if(fixType_ == ThumbnailFixedType.HEIGHT_FIX)
                {
                    float width = fixLength_ * ori_size_.Width / ori_size_.Height;
                    return new Size((int)width,(int)fixLength_);
                }
                else
                {
                    float height = 0;
                    if(ori_size_.Height > ori_size_.Width)
                    {
                        height = 498;
                    }
                    else
                    {
                        height = 240;
                    }
                    //float height = Utils.MIN(fixLength_ * ori_size_.Height / ori_size_.Width, 444);
                    return new SizeF(fixLength_, height);
                }
            }
        }
    }
}
